package com.roy.galaxy.algorithm;

import java.util.ArrayList;

/**
 * @author gang.wang1903@xiaobao100.cn
 * @Date: 2019-09-23 18:39
 */
public class Solution {


    /**
     * 二维数组查找查找字
     * @param target
     * @param array
     * @return
     */
    public static boolean Find(int target, int [][] array) {

        for(int i = 0  ; i < array.length ; i ++ ){

            for(int j = 0  ; j < array[0].length ; j ++ ){

                if(array[i][j] == target){
                    return true;
                }
                if(array[i][j] > target){
                    break;
                }
            }
        }

        return false;
    }


    /**
     * 字符替换
     * @param str
     * @return
     */
    public static String replaceSpace(StringBuffer str) {
        StringBuffer newStr = new StringBuffer();
        for(int i = 0 ; i < str.length() ; i ++){
            String s = String.valueOf(str.charAt(i));
            if(s.equals(" ")){
                newStr.append("%20");
            }else {
                newStr.append(str.charAt(i));
            }
        }

        return newStr.toString();
    }


    public static void main(String[] args) {
        ListNode parent = new ListNode();
        parent.setVal(1);

        ListNode child = new ListNode();
        child.setVal(1);
        child.setNext(null);

        parent.setNext(child);

        ArrayList<Integer> arrayList = new ArrayList<>();

        new Solution().printListFromTailToHead(parent);

        System.out.print("test");

    }






    ArrayList<Integer> arrayList=new ArrayList<Integer>();
    public  ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
        if(listNode!=null){
            this.printListFromTailToHead(listNode.next);
            arrayList.add(listNode.val);
        }
        return arrayList;
    }



    static   class ListNode {

        int val;

        ListNode next = null;

        public int getVal() {
            return val;
        }

        public void setVal(int val) {
            this.val = val;
        }

        public ListNode getNext() {
            return next;
        }

        public void setNext(ListNode next) {
            this.next = next;
        }

    }








}